//package com.cc.service;
//
//import com.cc.annotation.MeSelfAutowired;
//import org.springframework.beans.BeansException;
//import org.springframework.beans.factory.config.BeanPostProcessor;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.ApplicationContextAware;
//import org.springframework.stereotype.Component;
//
//import java.lang.reflect.Field;
//
///**
// * @title: MeBeanPostProcessor
// * @author: lbj
// * @date: 2022/5/7 11:29 上午
// * @description: TODO 类描述
// */
//
//@Component
//public class MeBeanPostProcessor implements BeanPostProcessor, ApplicationContextAware {
//
//    private ApplicationContext applicationContext;
//
//    @Override
//    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
//        final Class<?> aClass = bean.getClass();
//        for (Field field : aClass.getDeclaredFields()) {
//            if (field.isAnnotationPresent(MeSelfAutowired.class)) {
//                field.setAccessible(true);
//
//                final Object autowiredBean = applicationContext.getBean(field.getName());
//                try {
//                    field.set(bean,autowiredBean);
//                } catch (IllegalAccessException e) {
//                    e.printStackTrace();
//                }
//            }
//        }
//        return bean;
//    }
//
//    @Override
//    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
//        this.applicationContext = applicationContext;
//    }
//}
